<template>
	<div class="bg-act-box">
		<el-dialog
			:title="title"
		    :visible.sync="dialogVisible"
		  	width="30%"
		  	:before-close="handleClose">
		  	<div class="o-u-box">
				<span class="m-s-txt-lb">{{title}}:</span>
				<el-image
				      style="width: 100px; height: 100px"
				      :src="url"></el-image>
				<div class="u-btn" @click.stop="chooseImg">+上传替换</div> 
		  	</div>
		</el-dialog>
	</div>
</template>

<script>
	import uploadPic from "@/js/upload/UploadPic.js";
	import staticConst from "@/js/const/StaticConst.js";
	export default
	{
		data()
		{
			return{
				title:"",
				dialogVisible:false,
				color1:"#3388FF",
				radio: '1',
				radioBg:"1",
				url:"",
				act : "",
				
			}
		},
		
		methods:
		{
			showWin(data)
			{
				this.dialogVisible = true;
				console.log("showWin===:",data);
				this.act = data.act;
				this.url = data.data;
				if(data.act == 'main_banner_pic')//广告图片
				{
					this.title = "标题图片";
				}
				else if(data.act == 'edit_cp_logo')//edit_cp_logo",//编辑企业logo 
				{
					this.title = '店铺logo'
				}
			},
			
			handleClose()
			{
				this.dialogVisible = false;
			},
			
			chooseImg()
			{
				let that = this;
				uploadPic.idyun = 22;
				uploadPic.activeId = 1;
				uploadPic.type = staticConst.UPLOAD_INTER_ACTIVE;
				uploadPic.uploadSussecc = uploadSuccess;
				uploadPic.chooseImage1(callBack);
				function callBack(data)
				{
					that.url = data.url;  //显示图片
				}
				
				function uploadSuccess(data)
				{
					let obj = {};
					obj.act= that.act;
					obj.url = data.url;
					obj.baseUrl = data.name;
					that.$emit("editAdBg",obj);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	
	.bg-act-box
	{
		::v-deep.el-dialog
		{
			margin-top: 40vh !important;
		}
	}
	
	.m-s-txt-lb
	{
		padding-right: 10px;
	}
	.o-u-box
	{
		display:flex;
		align-items: center;
		padding-top: 20px;
		.u-btn
		{
			margin-left: 10px;
			padding: 4px 20px;
			background-color: #3388FF;
			color:#FFF;
			border-radius: 4px;
			cursor: pointer;
		}
	}
	
</style>